package com.example.admin.controller.web.system;

import java.util.Arrays;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.common.system.entity.RoleEntity;
import com.example.common.system.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.example.common.util.PageUtils;
import com.example.common.core.response.AjaxResult;



/**
 * 系统角色表
 *
 * @author chen
 * @email 17635014889@163.com
 * @date 2022-09-20 10:33:50
 */
@RestController
@RequestMapping("/system/role")
public class RoleController {
    @Autowired
    private RoleService roleService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("system:role:list")
    public AjaxResult list(Page<RoleEntity> page, RoleEntity roleEntity){
        PageUtils result = roleService.queryPage(page,roleEntity);

        return AjaxResult.success(result);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("system:role:info")
    public AjaxResult info(@PathVariable("id") Long id){
		RoleEntity role = roleService.getById(id);

        return AjaxResult.success(role);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("system:role:save")
    public AjaxResult save(@RequestBody RoleEntity role){
		roleService.save(role);

        return AjaxResult.success();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("system:role:update")
    public AjaxResult update(@RequestBody RoleEntity role){
		roleService.updateById(role);

        return AjaxResult.success();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("system:role:delete")
    public AjaxResult delete(@RequestBody Long[] ids){
		roleService.removeByIds(Arrays.asList(ids));

        return AjaxResult.success();
    }

}
